public class KgcClass {
    String name, dirTeacher, startDate;
    String[] stus = new String[10];

    public void add(String name) {
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] == null) {
                break;
            } else if (name.equals(stus[i])) {
                System.out.println("添加失败，错误");
                return;
            }
        }
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] == null) {
                stus[i] = name;
                return;
            }
        }
    }

    public void showInformation() {
        System.out.println("班级名称：" + name);
        System.out.println("指导老师：" + dirTeacher);
        System.out.println("学生信息如下：");
        for (int j = 0; j < stus.length; j++) {
            System.out.print(stus[j] + " ");
        }
    }

    public Boolean findName(String name) {
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] == null) {
                return false;
            } else if (name.equals(stus[i])) {
                return true;
            }
        }
        return false;
    }

    public String find(int index) {
        int i;
        for (i = 0; i < stus.length; i++)
            if (stus[i] == null) {
                break;
            }
        if (index >= i) return "越界！";
        else return "找到了，是" + stus[index];
    }

    public boolean update(String oldName, String newName) {
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] == null) {
                return false;
            } else if (oldName.equals(stus[i])) {
                stus[i] = newName;
                return true;
            }
        }
        return false;
    }

    public int getNum() {
        int i;
        for (i = 0; i < stus.length; i++) {
            if (stus[i] == null) {
                return i + 1;
            }
        }
        return i;
    }
}